package io.in.fileinputstream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * FileInputStream是InputStream的子类，
 * 在FileInputStream中没有特有的方法需要我们学习，
 * 所以我们使用FileInputStream读取数据的方式和InputStream
 */
public class FileInputStreamDemo {

    //入口
    public static void main(String[] args) throws IOException {
        //创建FileInputStream对象
        FileInputStream fileInputStream = new FileInputStream("G:\\heima\\itheima-hello-git\\Day10\\src\\io\\in\\fileinputstream\\text.txt");

        //读取数据
        //单个字节读取
        //int by = fileInputStream.read();
        //System.out.println((char) by);

        /*int by= -1;
        while((by = fileInputStream.read())!=-1){
            System.out.print((char)by);
        }*/

        //读取一个字节数组
        byte [] by= new byte[5];
        /*int read = fileInputStream.read(by);
        System.out.println(new String(by));*/
        int len = -1 ;
        while((len = fileInputStream.read(by))!=-1){
            System.out.print(new String(by));
        }





        //释放资源

        fileInputStream.close();


    }
}
